package com.justcan.demo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import java.util.List;

/**
 * Created by justcan on 2018/3/20.
 */

public class DemoAdapter extends BaseAdapter {
    private Context context;
    private List<String> temps;
    private LayoutInflater inflater;

    public DemoAdapter(Context context, List<String> temps) {
        this.context = context;
        this.temps = temps;
        this.inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return temps == null ? 0 : temps.size();
    }

    @Override
    public Object getItem(int i) {
        return temps == null ? null : temps.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = inflater.inflate(R.layout.action_habit_list_item_layout, null);
        }
        return view;
    }
}
